home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / ds3100.md / gdb / RCS / coredep.c,v < prev    next >
Encoding:
Text File  |  1992-07-01  |  3.6 KB  |  136 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     92.06.17.11.48.36;  author secor;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* Extract registers from a "standard" core file, for GDB.
  26.    Copyright (C) 1988-1991  Free Software Foundation, Inc.
  27.  
  28. This file is part of GDB.
  29.  
  30. This program is free software; you can redistribute it and/or modify
  31. it under the terms of the GNU General Public License as published by
  32. the Free Software Foundation; either version 2 of the License, or
  33. (at your option) any later version.
  34.  
  35. This program is distributed in the hope that it will be useful,
  36. but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  38. GNU General Public License for more details.
  39.  
  40. You should have received a copy of the GNU General Public License
  41. along with this program; if not, write to the Free Software
  42. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  43.  
  44. /* core.c is supposed to be the more machine-independent aspects of this;
  45.    this file is more machine-specific.  */
  46.  
  47. #include "defs.h"
  48. #include <sys/types.h>
  49. #include <sys/param.h>
  50. #include "gdbcore.h"
  51.  
  52. /* These are needed on various systems to expand REGISTER_U_ADDR.  */
  53. #ifndef USG
  54. #include <sys/dir.h>
  55. #include <sys/file.h>
  56. #include <sys/stat.h>
  57. #include <sys/user.h>
  58. #include "ptrace.h"
  59. #endif
  60.  
  61. /* Extract the register values out of the core file and store
  62.    them where `read_register' will find them.
  63.  
  64.    CORE_REG_SECT points to the register values themselves, read into memory.
  65.    CORE_REG_SIZE is the size of that area.
  66.    WHICH says which set of registers we are handling (0 = int, 2 = float
  67.          on machines where they are discontiguous).
  68.    REG_ADDR is the offset from u.u_ar0 to the register values relative to
  69.             core_reg_sect.  This is used with old-fashioned core files to
  70.         locate the registers in a large upage-plus-stack ".reg" section.
  71.         Original upage address X is at location core_reg_sect+x+reg_addr.
  72.  */
  73.  
  74. void
  75. fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
  76.      char *core_reg_sect;
  77.      unsigned core_reg_size;
  78.      int which;
  79.      unsigned reg_addr;
  80. {
  81.   register int regno;
  82.   register unsigned int addr;
  83.   int bad_reg = -1;
  84.   register reg_ptr = -reg_addr;        /* Original u.u_ar0 is -reg_addr. */
  85.  
  86.   /* If u.u_ar0 was an absolute address in the core file, relativize it now,
  87.      so we can use it as an offset into core_reg_sect.  When we're done,
  88.      "register 0" will be at core_reg_sect+reg_ptr, and we can use
  89.      register_addr to offset to the other registers.  If this is a modern
  90.      core file without a upage, reg_ptr will be zero and this is all a big
  91.      NOP.  */
  92.   if (reg_ptr > core_reg_size)
  93.     reg_ptr -= KERNEL_U_ADDR;
  94.   if (reg_ptr > core_reg_size)
  95.     fprintf (stderr, "Can't find registers in core file\n");
  96.  
  97.   for (regno = 0; regno < NUM_REGS; regno++)
  98.     {
  99.       addr = register_addr (regno, reg_ptr);
  100.       if (addr >= core_reg_size) {
  101.     if (bad_reg < 0)
  102.       bad_reg = regno;
  103.       } else {
  104.     supply_register (regno, core_reg_sect + addr);
  105.       }
  106.     }
  107.   if (bad_reg >= 0)
  108.     {
  109.       error ("Register %s not found in core file.", reg_names[bad_reg]);
  110.     }
  111. }
  112.  
  113.  
  114. #ifdef REGISTER_U_ADDR
  115.  
  116. /* Return the address in the core dump or inferior of register REGNO.
  117.    BLOCKEND is the address of the end of the user structure.  */
  118.  
  119. unsigned int
  120. register_addr (regno, blockend)
  121.      int regno;
  122.      int blockend;
  123. {
  124.   int addr;
  125.  
  126.   if (regno < 0 || regno >= NUM_REGS)
  127.     error ("Invalid register number %d.", regno);
  128.  
  129.   REGISTER_U_ADDR (addr, blockend, regno);
  130.  
  131.   return addr;
  132. }
  133.  
  134. #endif /* REGISTER_U_ADDR */
  135. @
  136.